package browser;

import com.example.android.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.Toast;

public class ExemploSubMenu extends Activity {
	
	public void onCreate(Bundle icicle){
		super.onCreate(icicle);
		setContentView(R.layout.alerta_dialog);
	}	
		
		public boolean onCreateOptionsMenu(Menu menu){
			super.onCreateOptionsMenu(menu);
			MenuItem item = menu.add(0,0,0,"Novo");
			item=menu.add(0,1,0,"Salvar");
			item.setIcon(R.drawable.smile);
			item = menu.add(0,2,0, "Excluir");
			item.setIcon(R.drawable.smile2);
			
			SubMenu subMenu = menu.addSubMenu(0,3,0, "Outros");
			item = subMenu.add(0,4,0,"Pesquisar");
			item = subMenu.add(0,5,0,"Limpar");
			item = subMenu.add(0,6,0,"Sair");
			
					
			return true;
			
		}
		
		public boolean onMenuItemSelected(int featuredId, MenuItem item){
	    	switch (item.getItemId()){
	    	case 0:
	    		Toast.makeText(ExemploSubMenu.this, "Novo!", Toast.LENGTH_SHORT).show();
	    		break;
	    	case 1:
	    		Toast.makeText(ExemploSubMenu.this, "Sair!", Toast.LENGTH_SHORT).show();
	    		break;
	    	case 2:
	    		Toast.makeText(ExemploSubMenu.this, "Excluir!", Toast.LENGTH_SHORT).show();
	    		break;
	    		
	    	}
	    	return false;

}

}
